<%--
  Created by IntelliJ IDEA.
  User: A
  Date: 2024/4/24
  Time: 9:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="../../static/layui/css/layui.css">
    <script src="../../static/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../static/mylayer.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../static/kindeditor/kindeditor.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
    <%--添加form表单--%>

    <form class="layui-form" action="">
        <div class="layui-form-item">
            <br>
            <label class="layui-form-label">博客分类</label>
            <div class="layui-input-inline layui-input-wrap">
                <input type="text" name="type" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="submitAdd">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script>
        layui.use(['form'], function(){
            var form = layui.form;
            form.on('submit(submitAdd)',function (data) {
                var field = data.field;
                console.log(data);
                $.post(
                    '/type?method=add',
                    field,
                    function (result) {
                        console.log(result);
                        if (result.code == 0) {
                            mylayer.okMsg(result.msg);
                            // layer.close(index);
                            // table.reload('tableId');
                            setInterval(function() {
                                //关闭弹出框
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                //刷新父页面
                                window.parent.location.reload();
                            }, 2000)
                        } else {
                            mylayer.errorMsg(result.msg);
                        }
                    },
                    'json'
                );
                return false;
            });
        });

    </script>
</body>
</html>
